#!/bin/bash -e

function info() {
    echo Usage: `basename $0` '[-wrb] r1 r2'
    exit 1
}

while getopts ":p:f:w:r:b:" opt; do
    case  $opt  in
        p) out_prefix=$OPTARG;;
        f) suffix=$OPTARG;;
        w) win_len=$OPTARG;;
        r) read_th=$OPTARG;;
        b) bed=$OPTARG;;
        *) info;;
    esac
done
shift $(($OPTIND - 1))

if [ $# -lt 1 ]; then info; fi

. $var

# -Q no quality filter
# -q min quality
# -u max base percent of min quality
# -n max bases of N
# -l min length of read
# -L no length filter
# -y use low complexity filter
# -Y low complexity filter value
# -A no cut adapter
# -a adapter seq
# -5 trim 5' low base
# -3 trim 3' low base
# -W base trim window size
# -M base trim min mean quality
# -c correaction base quality by pair read overlap
# -U umi processing
# --umi_loc umi location, index1 or read1
# --umi_len 6
# --umi_prefix umi
# -p overrepresentation analysis
# -P split to N parts and only use one part to -p
# -w threads

adp_r1=AGTCAGAGA
adp_r2=AGATCGGAAGA
umi_len=6
# umi_skip=9
umi_skip=6
# trim3_r1=1
# trim3_r2=1
trim3_r1=0
trim3_r2=0
trim5_r1=0
trim5_r2=0

fastp \
-i $1 -I $2 \
-o $out_prefix.1.fq -O $out_prefix.2.fq \
--adapter_sequence $adp_r1 \
--adapter_sequence_r2 $adp_r2 \
-f $trim5_r1 \
-t $trim3_r1 \
-F $trim5_r2 \
-T $trim3_r2 \
-3 \
-q 20 -u 30 \
-l 30 \
-U --umi_loc per_read --umi_len $umi_len --umi_skip $umi_skip \
-p -P 20 \
-w 6 \
-h $out_prefix.0.html \
-j $out_prefix.0.json \
-R "$1 and $2 report"


# umi_skip c yY l L u q
adp_r1=TCGTATGCCGT
adp_r2=ATCGGAAGAGC
fastp \
-i $out_prefix.1.fq -I $out_prefix.2.fq \
-o $out_prefix.r1.fq -O $out_prefix.r2.fq \
--adapter_sequence $adp_r1 \
--adapter_sequence_r2 $adp_r2 \
-3 \
-l 30 \
-w 6 \
-h $out_prefix.html \
-j $out_prefix.json \
-R "$out_prefix.1.fq and $out_prefix.2.fq report"

# -c


